/*
*  Copyright 2019-2020 Zheng Jie
*
*  Licensed under the Apache License, Version 2.0 (the "License");
*  you may not use this file except in compliance with the License.
*  You may obtain a copy of the License at
*
*  http://www.apache.org/licenses/LICENSE-2.0
*
*  Unless required by applicable law or agreed to in writing, software
*  distributed under the License is distributed on an "AS IS" BASIS,
*  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
*  See the License for the specific language governing permissions and
*  limitations under the License.
*/
package me.zhengjie.modules.workflow.domain;

import lombok.Data;
import cn.hutool.core.bean.BeanUtil;
import io.swagger.annotations.ApiModelProperty;
import cn.hutool.core.bean.copier.CopyOptions;
import org.hibernate.annotations.UpdateTimestamp;

import javax.persistence.*;
import java.sql.Timestamp;
import java.io.Serializable;

/**
* @website https://el-admin.vip
* @description /
* @author wzp
* @date 2021-05-08
**/
@Entity
@Data
@Table(name="act_ru_task")
public class ActRuTask implements Serializable {

    @Id
    @Column(name = "ID_")
    @ApiModelProperty(value = "主键")
    private String id;

    @Column(name = "REV_")
    @ApiModelProperty(value = "版本")
    private Integer rev;

    @Column(name = "EXECUTION_ID_")
    @ApiModelProperty(value = "任务对应执行流ID")
    private String executionId;

    @Column(name = "PROC_INST_ID_")
    @ApiModelProperty(value = "流程实例ID")
    private String procInstId;

    @Column(name = "PROC_DEF_ID_")
    @ApiModelProperty(value = "任务对应流程定义ID")
    private String procDefId;

    @Column(name = "NAME_")
    @ApiModelProperty(value = "任务名称")
    private String name;

    @Column(name = "PARENT_TASK_ID_")
    @ApiModelProperty(value = "父任务ID")
    private String parentTaskId;

    @Column(name = "DESCRIPTION_")
    @ApiModelProperty(value = "任务描述")
    private String description;

    @Column(name = "TASK_DEF_KEY_")
    @ApiModelProperty(value = "taskDefKey")
    private String taskDefKey;

    @Column(name = "OWNER_")
    @ApiModelProperty(value = "任务拥有人")
    private String owner;

    @Column(name = "ASSIGNEE_")
    @ApiModelProperty(value = "需要执行任务人")
    private String assignee;

    @Transient
    @ApiModelProperty(value = "任务拥有人名称")
    private String ownerName;

    @Transient
    @ApiModelProperty(value = "需要执行任务人名称")
    private String assigneeName;

    @Column(name = "DELEGATION_")
    @ApiModelProperty(value = "任务被委派的状态")
    private String delegation;

    @Column(name = "PRIORITY_")
    @ApiModelProperty(value = "优先级")
    private Integer priority;

    @Column(name = "CREATE_TIME_")
    @UpdateTimestamp
    @ApiModelProperty(value = "创建时间")
    private Timestamp createTime;

    @Column(name = "DUE_DATE_")
    @ApiModelProperty(value = "预定日期")
    private Timestamp dueDate;

    @Column(name = "CATEGORY_")
    @ApiModelProperty(value = "任务类型")
    private String category;

    @Column(name = "SUSPENSION_STATE_")
    @ApiModelProperty(value = "任务状态")
    private Integer suspensionState;

    @Column(name = "TENANT_ID_")
    @ApiModelProperty(value = "多租户")
    private String tenantId;

    @Column(name = "FORM_KEY_")
    @ApiModelProperty(value = "表单KEY")
    private String formKey;

    @Column(name = "CLAIM_TIME_")
    @ApiModelProperty(value = "任务提醒时间")
    private Timestamp claimTime;

    public void copy(ActRuTask source){
        BeanUtil.copyProperties(source,this, CopyOptions.create().setIgnoreNullValue(true));
    }
}